package com.kangyi.admin.service.Impl;

import cn.hutool.core.collection.CollUtil;
import com.kangyi.admin.mapper.RegionMapper;
import com.kangyi.admin.service.RegionService;
import com.kangyi.constant.MessageConstant;
import com.kangyi.exception.DataNotExistException;

import com.kangyi.vo.RegionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Service
public class RegionServiceImpl implements RegionService {

    @Autowired
    private RegionMapper regionMapper;

    @Override
    public List<RegionVO> inquiryRegion() {
        List<RegionVO> regionVOList = regionMapper.inquiryRegion();
        if (CollUtil.isEmpty(regionVOList)) {
            throw new DataNotExistException(MessageConstant.DATA_NOT_EXIST);
        }
        return regionVOList;
    }

    @Override
    public List<String> getAllCities() {
        return regionMapper.getAllCities();
    }

    @Override
    public List<RegionVO> getDistrictsByCity(String city) {
        return regionMapper.getDistrictsByCity(city);
    }
}
